package bitmap

import (
	"strings"
)

const (
	bitSize = 8
	shift   = 3
	mask    = 7
)

func indexAndPos(num int) (int, int) {
	// 相当于n/8, n%8  h%2^n = h & (2^n - 1)
	return num >> shift, num & mask
}

func byteToString(b byte) string {
	var sb strings.Builder
	for i := uint(0); i < bitSize; i++ {
		if b&(1<<i) == 0 {
			sb.WriteString("0")
		} else {
			sb.WriteString("1")
		}
	}

	return sb.String()
}
